package com.moli.iov.sys.component;

import com.moli.iov.util.Md5PwdEncoder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * <p>
 * 密码校验
 * </p>
 *
 * @author zql
 * @since 2019/9/26 12:54
 */
@Component
public class CredentialsMatcher {

  @Value("${pwd.salt}")
  private String salt;

  /**
   * 密码校验
   * @param rawPwd 用户输入的密码
   * @param pwd    数据库中密码
   * @return
   */
  public boolean doCredentialsMatch(String rawPwd, String pwd) {

    String rawP = Md5PwdEncoder.encodePassword(rawPwd, salt);

    return pwd.equals(rawP);
  }
}
